package com.bwie.system.controller;

import com.bwie.common.domain.*;
import com.bwie.common.domain.request.ShopRequest;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.system.service.ShopService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author：作者姓名
 * @Package：com.bwie.system.controller
 * @Project：_yk
 * @name：ShopController
 * @Date：2024/5/17 10:36
 */
@RestController
@RequestMapping("/Shop")
public class ShopController {

    @Autowired
    private ShopService shopService;

    @PostMapping("/toShop")
    public Result<List<Favorable>> list(@RequestBody ShopRequest shopRequest){
        List<Favorable> list = shopService.List(shopRequest);
        return Result.success(list);
    }

    @PostMapping("/get")
    public Result<List<Gett>> Find(){
        List<Gett> find = shopService.Find();
        return Result.success(find);
    }

    @PostMapping("/type")
    public Result<List<Type>> type(){
        List<Type> find = shopService.type();
        return Result.success(find);
    }

    @PostMapping("/cate")
    public Result<List<Cate>> cate(){
        List<Cate> find = shopService.cate();
        return Result.success(find);
    }

    @PostMapping("/shop")
    public Result<List<Shop>> shop(@RequestBody Shop shop){
        List<Shop> find = shopService.shop(shop);
        return Result.success(find);
    }

    @PostMapping("/mall")
    public Result<List<MallVo>> mall(){
        List<MallVo> find = shopService.mall();
        return Result.success(find);
    }

    @PostMapping("/cat")
    public Result<List<Cat>> cat(){
        List<Cat> find = shopService.cat();
        return Result.success(find);
    }

@PostMapping("/shops")
    public Result<List<Shop>> shops(){
        List<Shop> find = shopService.shops();
        return Result.success(find);
    }

    @PostMapping("/Shoppings")
    public Result<PageResult<Shop>> Shoppings(){
        List<Shop> find = shopService.Shoppings();
        PageInfo<Shop> info = new PageInfo<>(find);
        return PageResult.toResult(info.getTotal(), find);
    }

    @PostMapping("/ShopAdd")
    public Result ShopAdd(@RequestBody Shop shop){
        Integer i = shopService.ShopAdd(shop);
        return Result.success(i);
    }

    @PostMapping("/Del")
    public Result Del(@RequestParam Integer pri,String userName){
        Integer i = shopService.Del(pri,userName);
        return Result.success(i);
    }

    @PostMapping("/ShopAdds")
    public Result ShopAdds(@RequestBody List<Shop> shop){
        Integer i = shopService.ShopAdds(shop);
        return Result.success(i);
    }













}

